const {
	db,
	dbCmd,
	result_success,
	result_error,
	appletInfoCollection,
	shopieCollection
} = require('../../common/constants')
const {
	mainSpaceId
} = require('config-main-space')
const mycloud = uniCloud.init({
	provider: 'tencent',
	spaceId: mainSpaceId
})
const wmzWechatSdk = mycloud.importObject('wmz-wechat-sdk')
module.exports = async function(params = {}) {
	const token = this.getUniIdToken()
	if (!token) {
		return result_error('登录失效,请重新登录')
	}
	let payload = await this.uniID.checkToken(token)
	if (payload.code) {
		return payload
	}
	let id = params.id
	let shopieData = await shopieCollection.doc(id).get()
	shopieData = shopieData.data[0]
	return result_success(shopieData)
}